package fresponse

import "github.com/gin-gonic/gin"

type MJson interface {
	response
}

type json struct {
	data   any
	code   int
	option *Option
}

func (j *json) Assemble(ctx *gin.Context) {
	ctx.JSON(j.option.HttpCode, gin.H{
		"code": j.code,
		"data": j.data,
	})
}

func Json(code int, data any, config ...*Option) MJson {
	return &json{data: data, code: code, option: option(config...)}
}
